
const dao = require("../dao/search")
const response = require("../utils/response")

/**
 * 按照条件搜索post信息，补充user、各种数量、upvoted等
 * 从第start条开始，返回count条（下标0开始）
 * @param {*} data {user_id, start, count, search_text, options}}
 */
async function search_fullposts(data) {
    var res = await dao.search_fullposts(data.user_id, data.search_text, data.start, data.count, data.options);
    return response.ok(res);
}

/**
 * 按照条件搜索一级comment信息，补充user、各种数量、upvoted等
 * @param {*} data {user_id, post_id, method(time, fever)}}
 */
async function search_fullcomments1(data) {
    var res = await dao.search_fullcomments1(data.user_id, data.post_id, data.method);
    return response.ok(res);
}

/**
 * 搜索二三级comment信息，补充user、各种数量、upvoted等
 * @param {*} data {user_id, father_id}}
 */
async function search_fullcomments23(data) {
    var res = await dao.search_fullcomments23(data.user_id, data.father_id);
    return response.ok(res);
}


module.exports = {
    search_fullposts: search_fullposts,
    search_fullcomments1: search_fullcomments1,
    search_fullcomments23: search_fullcomments23,
}
